﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.SqlClient;
using System.Data.Common;

/// <summary>
/// 创建数据库连接的类，用以屏蔽不同测试平台的不同数据库
/// </summary>
public class DBConnector
{
    public const DBConnectionType DEFAULT_CONNECTION_TYPE = DBConnectionType.SQLite;

    public DBConnector()
    {

    }

    DBConnectorBase CreateConnector(DBConnectionType connecton_type)
    {
        DBConnectorBase connector = null;
        switch (connecton_type)
        {
            case DBConnectionType.SQLite:
                connector = new SQLiteDBConnector();
                break;
            default:
                connector = new SQLiteDBConnector();
                break;
        }

        return connector;
    }

    public DbConnection GetConnection()
    {
        return CreateConnector(DEFAULT_CONNECTION_TYPE).GetConnection();
    }

    public DbDataAdapter GetAdapter(string cmd)
    {
        return CreateConnector(DEFAULT_CONNECTION_TYPE).GetDataAdapter(cmd);
    }

    public string DateTimeToString(DateTime time_to_convert)
    {
        return CreateConnector(DEFAULT_CONNECTION_TYPE).DateTimeToString(time_to_convert);
    }

    //SqlConnection GetSqlConnection()
    //{
    //    return null;
    //}

    //()
    //{
    //    return null;
    //}
}
